<template>
  <a-card :bordered="false">

    <div class="table-page-search-wrapper" v-if="hasPerm('sysRole:page')">
      <a-form layout="inline">
        <a-row :gutter="48">
          <a-col :md="6" :sm="24">
            <a-form-item label="租户名称">
              <a-input v-model.trim="queryParam.tenantName" allow-clear placeholder="请输入租户名称"/>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
            <a-button style="margin-left: 8px" @click="() => {queryParam = {},$refs.table.refresh()}">重置</a-button>
          </a-col>
        </a-row>

      </a-form>
    </div>

    <s-table
      ref="table"
      size="default"
      :columns="columns"
      :data="loadData"
      :alert="true"
      :rowKey="(record) => record.code"
      :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
    >
    </s-table>

  </a-card>
</template>

<script>
import { STable } from '@/components'
import { ledgerRecordsPage, resetPasswords, sysTenantEditStatus } from '@/api/modular/system/roleManage'

export default {
  components: {
    STable,
  },

  data () {
    return {
      loading: false,
      // 查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: '租户名称',
          dataIndex: 'tenantName'
        },
        {
          title: '分账金额',
          dataIndex: 'dividendAmount'
        },
        {
          title: '时间',
          dataIndex: 'time'
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        return ledgerRecordsPage(Object.assign(parameter, this.queryParam)).then((res) => {
          return res.data
        })
      },
      selectedRowKeys: [],
      selectedRows: []
    }
  },

  created () {
  },

  methods: {
    handleOk () {
      this.$refs.table.refresh()
    },
    onSelectChange (selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    }
  }

}
</script>

<style lang="less">
.table-operator {
  margin-bottom: 18px;
}
button {
  margin-right: 8px;
}

</style>
